﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TuyennvLibrary.Enum;

namespace TuyennvLibrary.Attributes
{
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true, Inherited = false)]
    public class AttributeDescriptionClass : Attribute, IComparable<AttributeDescriptionClass>
    {
        public static int Author = 1;
        public static int Class = 2;
        public static int Contructor = 3;
        /// <summary>
        /// Các kiểu cho mô tả thuộc giá trị 1,2: Ví dụ AttributeMethod.Class=1;
        /// </summary>
        public int TypeDescription { get; set; }
        /// <summary>
        /// Mô tả có thể dùng các thẻ html để hiển thị cho tốt
        /// </summary>
        public string Description { get; set; }
        public AttributeDescriptionClass(TypeDescriptionClass TypeDescription, string Description)
        {            
            this.TypeDescription = (int)TypeDescription;
            this.Description = Description;
        }
        public string getDescription(AttributeDescriptionClass attribute)
        {
            return attribute.ToString();
        }
        public override bool Equals(object obj)
        {
            if (this.TypeDescription == Author)
            {
                if (this.TypeDescription == ((AttributeDescriptionClass)obj).TypeDescription)
                    return true;
            }
            return false;
        }
        public override string ToString()
        {
            if (this.TypeDescription == AttributeDescriptionClass.Author)
                return "<i style=\"color:Red\">Author</i>: " + this.Description;
            if (this.TypeDescription == AttributeDescriptionClass.Class)
                return "<i style=\"color:Red\">Class</i>: " + this.Description;
            if (this.TypeDescription == AttributeDescriptionClass.Contructor)
                return "<i style=\"color:Red\">Contructor</i>: " + this.Description;
            return string.Empty;
        }
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        public int CompareTo(AttributeDescriptionClass other)
        {
            if (other == null)
                return 1;

            else
                return this.TypeDescription.CompareTo(other.TypeDescription);
        }
    }
}
